package com.shujia.transformation

import org.apache.flink.api.common.functions.MapFunction
import org.apache.flink.streaming.api.scala._

object Demo01Map {
  def main(args: Array[String]): Unit = {

    val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment

    val words: DataStream[String] = env.socketTextStream("master", 8888)
    // scala风格
    words.map(word => (word, 1)).print()
    // java风格
    words.map(new MapFunction[String, (String, Int)] {
      override def map(value: String): (String, Int) = {
        (value, 1)
      }
    }).print()

    env.execute()


  }

}
